﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DrinkTest.Question;

namespace DrinkTest.Answer
{
    class Edward : IDrinkTest
    {
        public long GetSumSat(int[] S, int[] A)
        {
            
            
            if (S.Length != A.Length) return 0;
            if (S.Length == 0) return -1;
            int t = 100;
            int Acount = 0;
            long Scount = 0;


            int max = 0;
            int maxposition = -1;

            while (Acount < t)
            {
                for (int i = 0; i < S.Length; i++)
                {
                    if (S[i] > max)
                    {
                        max = S[i];
                        maxposition = i;
                    }
                }
                if (max == 0) break;
                int needs = 0;
                if (Acount + A[maxposition] < 100)
                {
                    needs = A[maxposition];
                }
                else
                {
                    needs = A[maxposition] - (A[maxposition] - (t - Acount));
                }



                Scount += S[maxposition] * needs;


                Acount += A[maxposition];
                S[maxposition] = 0;
                max = 0;
            }
            if (Acount < t) return -1;
            
            return Scount;




            //Dictionary<int, int> dict = new Dictionary<int, int>();
            //for (int i = 0; i < S.Length; i++)
            //{
            //    dict.Add(S[i], A[i]);
            //}

            //while (Acount <= 100)
            //{
            //    dict.Max();

            //}

            
        }


        private static int Compare(KeyValuePair<int, int> a, KeyValuePair<int, int> b)
        {
            if (a.Key == b.Key)
            {
                return 0;
            }
            if (a.Key < b.Key) return 1;
            else return -1;

        }
    }
}
